﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DataTool
{
    partial class CONTEST
    {
        //public SUBMISSION getSubmission()
        //{

        //    wfdbEntities db = new wfdbEntities(); 
        //    db.ApplyCurrentValues("", this);
        //    db.CreateObjectSet<CONTEST>().Attach(this);
        //    db.ObjectStateManager.ChangeObjectState(this, EntityState.Modified);
        //    db.SaveChanges();
            
        //}

        //public CONTEST MakeSureImNotObsolete()
        //{
        //    wfdbEntities db = new wfdbEntities();
        //    this = db.CONTESTs.SingleOrDefault(x => x.Id == Id);
        //    return this;
        //}

        public CONTEST ContestFromDb(wfdbEntities db)
        {
            return db.CONTESTs.SingleOrDefault(x => x.Id == this.Id);
        }
    }

    partial class SUBMISSION
    {
        //public SUBMISSION getSubmission()
        //{

        //    wfdbEntities db = new wfdbEntities(); 
        //    db.ApplyCurrentValues("", this);
        //    db.CreateObjectSet<CONTEST>().Attach(this);
        //    db.ObjectStateManager.ChangeObjectState(this, EntityState.Modified);
        //    db.SaveChanges();

        //}

        //public CONTEST MakeSureImNotObsolete()
        //{
        //    wfdbEntities db = new wfdbEntities();
        //    this = db.CONTESTs.SingleOrDefault(x => x.Id == Id);
        //    return this;
        //}

        public SUBMISSION SubmissionFromDb(wfdbEntities db)
        {
            return db.SUBMISSIONs.SingleOrDefault(x => x.Id == this.Id);
        }
    }

    partial class NEWS
    {
        public void Publish()
        {
            wfdbEntities db = new wfdbEntities();
            db.NEWS.AddObject(this);
            db.SaveChanges();
        }
    }
}
